<?php
namespace app\admin\controller;

use app\common\controller\Common;
use think\Controller;
use think\Loader;
use think\Request;
use think\Url;
use think\Session;
use think\Config;
use think\Db;
/**
* 登录
* @author aierui github  https://github.com/Aierui
* @version 1.0 
*/
class Index extends Admin
{
	/**
	 * 后台登录首页
	 */
	public function index()
	{	
		$admin = session('admin');
		$user = Loader::model('User')->getUserById($admin['userinfo']['id']);
		$sum = Db::name('user')->where('share',$user['eth'])->sum('source');
		//查询大于直推大于1万的
		$max_count = Db::name('user')->where('share',$user['eth'])->where('source > 10000')->count();
		$count = Db::name('user')->where('share',$user['eth'])->where('source > 0')->count();
		$max_dt = Db::name('trade')->max('dt');
		$qu = Db::name('trade')->where('dt',$max_dt)->find();
		if(!$sum)
		{
			$sum =0;
		}
		if(!$qu)
		{
			$qu['rmb_price'] = 1;
			$qu['usd_price'] = 1/6;
		}
		//$qu['usd_price']=round($qu['usd_price'],2);
		$this->assign('qu', $qu);
		$this->assign('user', $user);
		$this->assign('user', $user);
		$this->assign('sum', $sum);
		$this->assign('max_count', $max_count);
		$this->assign('count', $count);
		return view();
	}
}